class Solution
{
private:
    vector<vector<int>> ans;
    void dfs(int start, int n, int k, vector<int>& path)
    {
        if (path.size() == k)
        {
            ans.push_back(path);
            return;
        }
        for (int i = start; i <= n; ++i)
        {
            path.push_back(i);
            dfs(i + 1, n, k, path);
            path.pop_back();
        }
    }

public:
    vector<vector<int>> combine(int n, int k)
    {
        vector<int> path;
        dfs(1, n, k, path);
        return ans;
    }
};